QuickTime 2.5 introduced a new way to draw still images. Graphics importer components provide a standard method for applications to open and display still images contained within graphics documents. Graphics importer components allow you to work with any type of image data, regardless of the file format or compression used in the document. You specify the document that contains the image, and the destination rectangle the image should be drawn into, and QuickTime handles the rest. More complex interactions are also supported.
The following example shows the basic functions you use to draw an image file.
void drawFile(const FSSpec *fss, const Rect *boundsRect)
{
GraphicsImportComponent gi;
GetGraphicsImporterForFile(fss, &gi);
GraphicsImportSetBoundsRect(gi, boundsRect);
GraphicsImportDraw(gi);
CloseComponent(gi);
}
The same code can be used to display any image, regardless of the file format. QuickTime 2.5 supports the following image file formats: QuickDraw PICT, MacPaint, Photoshop (2.5 and 3.0), Silicon Graphics.rgb, GIF, and JFIF/JPEG. The new QuickTime image file format is also supported.
To obtain a graphics importer component for a particular file, use the Image Compression Manager's GetGraphicsImporterForFile function.
If you expect to draw the same image more than once, you can improve performance by keeping the graphics importer component open, rather than creating and disposing it each time.